package com.sky.controller.user;

import com.sky.dto.CategoryDTO;
import com.sky.entity.Category;
import com.sky.result.Result;
import com.sky.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@RestController("userCategoryController")
@Slf4j
@Api(tags = "查询套餐/菜品分类相关接口")
@RequestMapping("/user/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    /**
     * 查询指定套餐id的套餐
     * @param categoryDTO
     * @return
     */
    @ApiOperation(value = "查询指定套餐id的套餐")
    @GetMapping("/list")
    public Result<List<Category>> getCategoryList(CategoryDTO categoryDTO) {
        log.info("categoryDTO:{}", categoryDTO);
        List<Category> categoryList = categoryService.list(categoryDTO.getType());
        return Result.success(categoryList);
    }

}
